package com.example.aop;


import com.example.annotation.Jurisdiction;
import com.example.service.IUserService;
import com.example.service.impl.UserServiceImpl;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.lang.reflect.Method;

/**
 * @author ChenXiaoBin
 * on 2019/5/21
 */
@Aspect
@Component
public class JurisdictionAop {

    @Autowired
    private IUserService userService;

    /**
     * 指定注解
     */
    @Pointcut("@annotation(com.example.annotation.Jurisdiction)")
    public void setConfines() {

    }

    @Around("setConfines()")
    public Object jurisdiction(JoinPoint joinPoint) throws Exception {
        MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
        Method method = methodSignature.getMethod();
        Jurisdiction jurisdiction = method.getAnnotation(Jurisdiction.class);
        String type = jurisdiction.type();
        return null;
    }
}
